﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DLTN.Entities;
using DLTN.Data;

public partial class Tour_Controls_ControlChiTietTourRight : System.Web.UI.UserControl
{
    AjaxControlToolkit.AccordionPane pn;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Params["SubTour"] != null)
            {
                H_IDSubTour.Value = Request.Params["SubTour"].ToString();
            }
            BindingTourToAcr();
        }
    }

    private void BindingTourToAcr()
    {
        int TotalRows = 0;

        // Get ID của loại tour thông qua subtour tương ứng               
        SubTour ent_Sub = DataRepository.SubTourProvider.GetById(Convert.ToInt32(H_IDSubTour.Value.ToString()));
        int idLoaiTour = ent_Sub.IdLoaiTour;

        // TList chứa các sub tour
        TList<SubTour> TList_SubTour = DataRepository.SubTourProvider.GetPaged("IdLoaiTour = " + idLoaiTour, "Id", 0, 4, out TotalRows);
        if (TList_SubTour.Count > 0)
        {
            Literal lbTitle;
            Literal lbContent;
            string strHTML_Header = "";
            string strHTML_Content = "";

                for (int i = 0; i < TList_SubTour.Count; i++)
                {
                    lbTitle = new Literal();
                    lbContent = new Literal();
                    strHTML_Header = "";
                    strHTML_Header += "<img src='../../../" + "Images/Travel.png' Width='26px' Height='21px' />";
                    strHTML_Header += "<font>" + TList_SubTour[i].TenSubTour + "</font>";
                    lbTitle.Text = strHTML_Header;

                    // Nội dung Tour tương ứng với Sub Tour
                    TList<Tour> TList_Tour = DataRepository.TourProvider.GetPaged("IdSubTour = " + TList_SubTour[i].Id, "Id Desc", 0, 8, out TotalRows);
                    if (TList_Tour.Count > 0)
                    {
                        strHTML_Content = "";
                        for (int j = 0; j < TList_Tour.Count; j++)
                        {
                            
                            strHTML_Content += "<div style='float:left'>";
                            strHTML_Content += "<img src='../../../" + "Images/dltn/bullet.png' />&nbsp;</div>";
                            strHTML_Content += "<a href='../../../" + "Tour/" + TList_Tour[j].Id + "/" + TList_Tour[j].IdSubTour + "/" + GetTieuDe(TList_Tour[j].TieuDe) + ".aspx'>" + TList_Tour[j].TieuDe + "</a><br/>";
                        }

                    }
                    else
                    {
                        strHTML_Content = "Chưa cập nhật dữ liệu";
                    }

                    lbContent.Text = strHTML_Content;

                    pn = new AjaxControlToolkit.AccordionPane();
                    pn.ID = "Pane" + i;
                    pn.HeaderContainer.Controls.Add(lbTitle);
                    pn.ContentContainer.Controls.Add(lbContent);

                    acrTourTrongNuoc.Panes.Add(pn);
                }
        }

    }


    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}